/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Date;

/**
 * <p>Project: javase202202 - Format1
 * <p>Powered by Lisi On 2022-05-27 17:36:12
 * <p>Created by IntelliJ IDEA
 *

 * @version 1.0
 * @since 17
 */
public class Format1 {
    public static void main(String[] args) {
        int id = 100;
        String name = "李四";
        short age = 18;
        System.out.println("编号："+id+"，姓名："+name+"，年龄："+age+"岁。");

        //格式化输出 %d 代表整数  %03d
        System.out.printf("编号：%d，姓名：%s，年龄：%d岁。%n",id,name,age);

        System.out.println(12342424);
        System.out.println(15);

        System.out.printf("%15d%n",12342424);
        System.out.printf("%15d%n",15);
        System.out.printf("%15d\n\n",15);

        //red 255 green 100 blue 30
        System.out.printf("%02x%n",255);
        System.out.printf("%02x%n",100);
        System.out.printf("%02x%n",30);


        System.out.println(String.format("%.2f --- %.5f",10f,20D));


        System.out.printf("%.2f%n%n",20.135);


        for (int i = 1; i <= 6; i++) {
            System.out.printf("\033[%dm%s\033[0m%n", 30 + i, "hello" + i);
            System.out.printf("\033[%dm%s\033[0m%n", 40 + i, "hello" + i);
        }

        System.out.println(System.currentTimeMillis());
        System.out.printf("%tF %<tT%n",System.currentTimeMillis());
        System.out.printf("%tF %<tT%n",new Date().getTime());


        for (int i = 0; i > 15; i++) {
            // <
            // 2$

            System.out.printf("%d %<02d %1$03d%n",i);
            System.out.printf("%d %02d %03d%n",i,i,i);


        }
    }
}
